package com.mc.algorithm;

import java.util.Scanner;

public class Hex {
	
	public static void execute(){
		Scanner sc = new Scanner(System.in);
		String str;
		while(sc.hasNext()){
			str = sc.next();
			int result = Integer.parseInt(str.substring(2), 16);
			System.out.println(result);
		}
	}
	public static void main(String[] args) {
		Hex.execute();
	}
}
